#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
int main() {
    ll sum = 2019 * 2019;
    ll MIN = INT_MAX;
    for (ll x = 2020; x < 10000; x++) {
        for (ll y = 2021; y < 10000; y++) {
            if (2 * x * x - y * y == sum) {
                MIN = min(MIN, x + y);
            } 
        }
    }
    cout << MIN << endl;
    return 0;

}